package com.ruoyi.project.hcy.notice.service;

import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.project.hcy.notice.domain.NoticeType;
import com.ruoyi.project.hcy.notice.mapper.NoticeTypeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NoticeTypeImpl implements INoticeTypeService {

    @Autowired
    private NoticeTypeMapper noticeTypeMapper;

    @Override
    public List<NoticeType> selectNoticeTypeList(NoticeType noticeType) {

        return noticeTypeMapper.selectNoticeTypeList(noticeType);
    }

    @Override
    public String checkNoticeTypeNameUnique(NoticeType noticeType) {
        return null;
    }

    /**
     * 新增
     * @param noticeType
     * @return
     */
    @Override
    public int insertNoticeType(NoticeType noticeType) {

        return noticeTypeMapper.insertNoticeType(noticeType);
    }

    /**
     * 删除
     * @param ids
     * @return
     */
    @Override
    public int deleteNoticeTypeByIds(String ids) {
        Integer[] postIds = Convert.toIntArray(ids);
//        for (Long postId : postIds)
////        {
////            Post post = selectPostById(postId);
////            if (countUserPostById(postId) > 0)
////            {
////                throw new BusinessException(String.format("%1$s已分配,不能删除", post.getPostName()));
////            }
////        }
        return noticeTypeMapper.deleteNoticeTypeByIds(postIds);

    }

    /**
     * 通过id查询数据
     * @param typeId
     * @return
     */
    @Override
    public NoticeType selectNoticeTypeById(Integer typeId) {

        return noticeTypeMapper.selectNoticeTypeById(typeId);
    }

    /**
     * 更新
     * @param noticeType
     * @return
     */
    @Override
    public int updateNoticeType(NoticeType noticeType) {
        return noticeTypeMapper.updateNoticeType(noticeType);
    }
}
